<template>
    <div style="margin-top: 5px;">
        <span @click="generateCode" class="bty-verify">{{ verificationCode }}</span>
    </div>
</template>

<script>
export default {
    data() {
        return {
            verificationCode: ''
        };
    },
    methods: {
        generateCode() {
            const length = 6; // 验证码长度
            const characters = 'abcdefjhijklmnopqrstuvwxyz0123456789';
            let code = '';
            for (let i = 0; i < length; i++) {
                const randomIndex = Math.floor(Math.random() * characters.length);
                code += characters.charAt(randomIndex);
            }
            this.verificationCode = code;
            window.localStorage.setItem("verify", code);
        }
    },
    mounted() {
        this.generateCode(); // 页面加载时生成验证码
    }
};
</script>

<style scoped>
.bty-verify{
    display: inline-block; 
    width: 65px;
    background-color: #87cce9;
    cursor: pointer;
    border-radius: 2px;
    text-align: center;
}
</style>